package com.project.config;

import com.project.interceptor.CustomInterceptor;
import com.project.interceptor.ManagerInterceptor;
import com.project.interceptor.SendInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MVCConfig implements WebMvcConfigurer {
    @Autowired
    private CustomInterceptor customInterceptor;
    @Autowired
    private SendInterceptor sendInterceptor;
    @Autowired
    private ManagerInterceptor managerInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration customReg = registry.addInterceptor(customInterceptor);
        customReg.addPathPatterns("/custom/**");
        InterceptorRegistration sendReg = registry.addInterceptor(sendInterceptor);
        sendReg.addPathPatterns("/static/send/**");
        InterceptorRegistration managerReg = registry.addInterceptor(managerInterceptor);
        managerReg.addPathPatterns("/manger/**");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/productImage/**")
                .addResourceLocations("file:C:/Users/zxl5815432/IdeaProjects/shopingProject/productImage/");
    }
}
